*Jillienne Haglund and Ryan M. Welch
*From Litigation to Rights
*Replication file

clear

log using "C:\Users\ryanm\Dropbox\Shared Research\RegionalCourt_NHRIPaper\Data\ISQ_Log.smcl"

set more off

set seed 32605

use "C:\Users\ryanm\Dropbox\Shared Research\RegionalCourt_NHRIPaper\Data\ISQ_ReplicationData.dta", clear

*Main Model (Table 1)
reg repressionlatent threeway numcasexcsoc nhrixcsoc numcasexnhri numcase hasnhri v2xcs_ccsi repressionlag lji xconst popmillionslog lgdp, cluster(cowcode)

*Model 2
reg repressionlatent numcasexcsoc numcase hasnhri v2xcs_ccsi repressionlag lji xconst popmillionslog lgdp, cluster(cowcode)

*Model 3
reg repressionlatent numcasexnhri numcase hasnhri v2xcs_ccsi repressionlag lji xconst popmillionslog lgdp, cluster(cowcode)

*Model 4
reg repressionlatent nhrixcsoc numcase hasnhri v2xcs_ccsi repressionlag lji xconst popmillionslog lgdp, cluster(cowcode)


***********************************************
*Figure 1
*Simulate predicted Values (90% CI)
estsimp reg repressionlatent threeway numcasexnhri numcasexcsoc nhrixcsoc numcase hasnhri v2xcs_ccsi repressionlag lji xconst popmillionslog lgdp

setx (threeway numcasexnhri numcasexcsoc nhrixcsoc numcase hasnhri v2xcs_ccsi) 1 (repressionlag lji popmillionslog lgdp) mean (xconst) median
simqi, level(95) 


setx (threeway numcasexnhri numcasexcsoc nhrixcsoc numcase hasnhri v2xcs_ccsi) 0 (repressionlag lji popmillionslog lgdp) mean (xconst) median
simqi, level(95) 


setx (threeway numcasexnhri numcasexcsoc nhrixcsoc hasnhri v2xcs_ccsi) 0 (numcase) 1 (repressionlag lji popmillionslog lgdp) mean (xconst) median
simqi, level(95) 


*Use those values to create a dot plot (2, 3, 1)

clear
input int x float(high low mean)
1 1.406119 1.221915 1.313068
2 1.425185 1.243272 1.335627
3 1.491822 1.462265 1.477144 
end

#delimit ;
twoway rcap high low x  || scatter mean x, mcolor(black) msize(small) legend(off) ///
xlabel(0 " " 1 2 3 4 " ") 
scheme(s1mono) ///
note("Note: Dots represent expected value; bars represent 95% confidence intervals."
	"1: No ruling, not enabling environment" 
	"2: Ruling, not enabling environment"
	"3: Ruling, enabling environment") ///
title("Simulated Human Rights Respect Scores") ///
ytitle("Expected Human Rights Respect Score") ///
xtitle("Condition") ///
name(graphx, replace);
#delimit cr

*Figure 2

*Open the data
clear
use "C:\Users\ryanm\Dropbox\Shared Research\RegionalCourt_NHRIPaper\Data\ISQ_ReplicationData.dta", clear

replace ecase_bin = 1 if numcase >= 1
replace ecase_bin = 0 if numcase < 1

*Upper Panel of Figure 2
reg repressionlatent i.ecase_bin##i.hasnhri##c.v2xcs_ccsi c.repressionlag c.lji c.xconst c.popmillions c.lgdp, cluster(cowcode)
margins 1.ecase_bin, at(v2xcs_ccsi = (0(.1)1) hasnhri = 1 (mean)repressionlag lji xconst popmillions lgdp)
marginsplot, title("ECtHR Judgments (1+) and NHRI Presence") ylabel(1.2(.1)1.5) xtitle(Civil Society) ytitle(Linear Prediction) level(90)
graph save upperpanel

*Lower Panel of Figure 2
reg repressionlatent i.ecase_bin##i.hasnhri##c.v2xcs_ccsi c.repressionlag c.lji c.xconst c.popmillions c.lgdp, cluster(cowcode)
margins 1.ecase_bin, at(v2xcs_ccsi = (0(.1)1) hasnhri = 0 (mean)repressionlag lji xconst popmillions lgdp)
marginsplot, title("ECtHR Judgments (1+) and NHRI Absence") ylabel(1.2(.1)1.5) xtitle(Civil Society) ytitle(Linear Prediction) level(90)
graph save lowerpanel

graph combine upperpanel.gph lowerpanel.gph, row(2)
graph save Figure2

******************************************************
***Appendix***

*Summary Statistics (Table 1)
sum repressionlatent numcase hasnhri v2xcs_ccsi lji xconst popmillionslog lgdp
**************************************************

*Robustness, Alternative DV: CIRI Physical Integrity (Table 2)
sort cowcode year
ologit ciri_physint threeway numcasexcsoc nhrixcsoc numcasexnhri numcase hasnhri v2xcs_ccsi l.ciri_physint lji xconst popmillionslog lgdp, cluster(cowcode)

*Robustness: DV as change in human rights (Table 2)
by cowcode: gen repressionlatent_change =  repressionlatent - repressionlatent[_n-1]
reg repressionlatent_change threeway numcasexcsoc nhrixcsoc numcasexnhri numcase hasnhri v2xcs_ccsi l.repressionlatent_change lji xconst popmillionslog lgdp, cluster(cowcode)
*********************************************************

*Robustness: HROs instead of Civil Society Index (Table 3)

*hrosecretariatlocation
hist hrosecretariatlocation
gen lnhrosecretariatlocation = ln(hrosecretariatlocation + 1)

gen numcaseXlnhrosecretariatlocation = numcase * lnhrosecretariatlocation
gen nhriXlnhrosecretariatlocation = hasnhri * lnhrosecretariatlocation
gen threeway5 = nhriXlnhrosecretariatlocation * numcase

reg repressionlatent threeway5  numcaseXlnhrosecretariatlocation nhriXlnhrosecretariatlocation numcasexnhri numcase hasnhri lnhrosecretariatlocation repressionlag lji xconst popmillionslog lgdp, cluster(cowcode)

*****************************************

*Robustness: Country fixed effects (Table 4)

*Generate dummy variables for countriees
gen uk = 0
replace uk = 1 if country == "United Kingdom"
gen ireland = 0
replace ireland = 1 if country == "Ireland"
gen netherlands = 0
replace netherlands = 1 if country == "Netherlands"
gen belgium = 0
replace belgium = 1 if country == "Belgium"
gen luxembourg = 0
replace luxembourg = 1 if country == "Luembourg"
gen france = 0
replace france = 1 if country == "France"
gen monaco = 0
replace monaco = 1 if cowcode == 221
gen liechtenstein = 0
replace liechtenstein = 1 if country == "Liechtenstein"
gen switzerland = 0
replace switzerland = 1 if country == "Switzerland"
gen spain = 0
replace spain = 1 if country == "Spain"
gen andorra = 0
replace andorra = 1 if cowcode == 232
gen portugal = 0
replace portugal = 1 if country == "Portugal"
gen germany = 0
replace germany = 1 if cowcode == 255
gen west_germany = 0
replace west_germany = 1 if cowcode == 260
gen east_germany = 0
replace east_germany = 1 if cowcode == 265
gen poland = 0
replace poland = 1 if cowcode == 290
gen austria = 0
replace austria = 1 if country == "Austria"
gen hungary = 0
replace hungary = 1 if cowcode == 310
gen czechoslovakia = 0
replace czechoslovakia = 1 if cowcode == 315
gen czech_republic = 0
replace czech_republic = 1 if cowcode == 316
gen slovakia = 0
replace slovakia = 1 if country == "Slovakia"
gen italy = 0
replace italy = 1 if country == "Italy"
gen san_marino = 0
replace san_marino = 1 if cowcode == 331
gen malta = 0
replace malta = 1 if country == "Malta"
gen albania = 0
replace albania = 1 if cowcode == 339
gen montenegro = 0
replace montenegro = 1 if cowcode == 341
gen serbia = 0
replace serbia = 1 if cowcode == 342
gen macedonia = 0
replace macedonia = 1 if cowcode == 343
gen croatia = 0
replace croatia = 1 if cowcode == 344
gen yugoslavia = 0
replace yugoslavia = 1 if cowcode == 345
gen bih = 0
replace bih = 1 if cowcode == 346
gen kosovo = 0
replace kosovo = 1 if cowcode == 347
gen slovenia = 0
replace slovenia = 1 if country == "Slovenia"
gen greece = 0
replace greece = 1 if country == "Greece"
gen cyprus = 0
replace cyprus = 1 if country == "Cyprus"
gen bulgaria = 0
replace bulgaria = 1 if cowcode == 355
gen moldova = 0
replace moldova = 1 if cowcode == 359
gen romania = 0
replace romania = 1 if cowcode == 360
gen russia = 0
replace russia = 1 if cowcode == 365
gen estonia = 0
replace estonia = 1 if cowcode == 366
gen latvia = 0
replace latvia = 1 if cowcode == 367
gen lithuania = 0
replace lithuania = 1 if country == "Lithuania"
gen ukraine = 0
replace ukraine = 1 if cowcode == 369
gen armenia = 0
replace armenia = 1 if cowcode == 371
gen georgia = 0
replace georgia = 1 if cowcode == 372
gen azerbaijan = 0
replace azerbaijan = 1 if cowcode == 373
gen finland = 0
replace finland = 1 if cowcode == 375
gen sweden = 0
replace sweden = 1 if country == "Sweden"
gen norway = 0
replace norway = 1 if country == "Norway"
gen denmark = 0
replace denmark = 1 if country == "Denmark"
gen iceland = 0
replace iceland = 1 if country == "Iceland"
gen turkey = 0
replace turkey = 1 if country == "Turkey"

*fixed effects model (UK reference category)

reg repressionlatent threeway numcasexcsoc nhrixcsoc numcasexnhri numcase hasnhri v2xcs_ccsi repressionlag lji xconst popmillionslog lgdp ireland netherlands belgium luxembourg france monaco liechtenstein switzerland spain andorra portugal germany west_germany east_germany poland austria hungary czechoslovakia czech_republic slovakia italy san_marino malta albania montenegro serbia macedonia croatia yugoslavia bih kosovo slovenia greece cyprus bulgaria moldova romania russia estonia latvia lithuania ukraine armenia georgia azerbaijan finland sweden norway denmark iceland turkey, cluster(cowcode)

****************************************

*Robustness: Year Fixed Effects (Table 4)
***Estimate with year fixed effects***

*create year dummies from 1980-2012
forvalues i = 1980/2012 {
	gen dum`i' = 0
	}

forvalues year = 1980/2012 {
	replace dum`year' = 1 if year == `year'
	}
	
reg repressionlatent threeway numcasexcsoc nhrixcsoc numcasexnhri numcase hasnhri v2xcs_ccsi repressionlag lji xconst popmillionslog lgdp dum1980-dum2012, cluster(cowcode)


*******************************************

*Selection: See ISQ_Matching_Final.R

********************************************

*Figure 1

*Appendix - Upper Left Panel of Figure 1 (Number of Adverse Judgments across Physical Integrity Rights) 
twoway (scatter repressionlatent numcase) if numcase >= 0 & numcase <= 15 || (lfit repressionlatent numcase), legend(off)

*Appendix - Upper Right Panel of Figure 1 (Number of Adverse Judgments across Civil Society)
twoway (scatter v2xcs_ccsi numcase) if numcase >= 0 & numcase <= 15 || (lfit v2xcs_ccsi numcase), legend(off)

*Appendix - Lower Left Panel of Figure 1 (number of Adverse Judgments across Electoral Democracy)
twoway (scatter v2x_polyarchy numcase) if numcase >= 0 & numcase <= 15 || (lfit v2x_polyarchy numcase), legend(off)

*Appendix - Lower Right Panel of Figure 1 (Number of Adverse Judgments Across Liberal Democracy)
twoway (scatter v2x_libdem numcase) if numcase >= 0 & numcase <= 15 || (lfit v2x_libdem numcase), legend(off)
*************************************************


*Robustness checks mentioned in manuscript, but not included in Appendix due to space constraints

*Executive Ideology
reg repressionlatent threeway numcasexcsoc nhrixcsoc numcasexnhri numcase hasnhri v2xcs_ccsi repressionlag lji xconst popmillionslog lgdp dpi_erlc, cluster(cowcode)
*************************************************

*Robustness Check: NHRI GANHRI(ICC) Grade instead of dichotomous
*create interaction terms
gen iccxcsoc = iccstatus*v2xcs_ccsi
gen numcasexiccstatus = numcase*iccstatus
gen threeway_icc = iccxcsoc*numcase

reg repressionlatent threeway_icc numcasexcsoc iccxcsoc numcasexiccstatus numcase iccstatus v2xcs_ccsi repressionlag lji xconst popmillionslog lgdp, cluster(cowcode)
***********************************************************

*Freedom House Rule of Law Measure Control
reg repressionlatent threeway numcasexcsoc nhrixcsoc numcasexnhri numcase hasnhri v2xcs_ccsi repressionlag lji xconst popmillionslog lgdp e_fh_rol, cluster(cowcode)

***********************************************

*Alternative Democracy Control (Polity)
reg repressionlatent threeway numcasexcsoc nhrixcsoc numcasexnhri numcase hasnhri v2xcs_ccsi repressionlag lji polity2 popmillionslog lgdp, cluster(cowcode)

***********************************************

log close
